package org.rency.mq.activemq.listener.factory.concurrent;

import org.rency.mq.activemq.listener.handler.MessageHandler;

public class MessageHandleTask implements Runnable {
	private MessageHandler messageHandler;
	private MessageHandleCallback messageHandleCallback;
	private Object request;
	private String taskId;

	public MessageHandleTask(MessageHandler messageHandler, Object request, MessageHandleCallback messageHandleCallback) {
		this.messageHandler = messageHandler;
		this.request = request;
		this.messageHandleCallback = messageHandleCallback;
		this.taskId = "" + System.nanoTime();
	}

	public void run() {
		messageHandler.handle(request);
		messageHandleCallback.handleRequestFinished(taskId, true);
	}

	public String getTaskId() {
		return taskId;
	}

}
